package com.example.yls.demoa;

import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import java.io.File;

public class MainActivity extends AppCompatActivity {
    private Button btnCreateDB;
    private Button btnCreateTable;
    private Button btnInsert;
    private SQLiteDatabase db;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnCreateDB=findViewById(R.id.btn_creatDB);
        btnCreateTable=findViewById(R.id.btn_creatTable);
        btnInsert=findViewById(R.id.btn_insert);

        btnCreateDB.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                createOrOpenDB();
            }

        });
    }
    private void createOrOpenDB() {
        String path= getFilesDir().getAbsolutePath()
                + File.separator +"stu,db";
        Log.e("MainActivity","path="+path);

        db=SQLiteDatabase.openOrCreateDatabase(path,null);

    }
}
